class Maybe {
  static of (value) {
    return new Maybe(value)
  }

  constructor (value) {
    this._value = value
  }

  isEmpty (value) {
    return [undefined, null].includes(value)
  }

  map (func) {
    return  Maybe.of(this.isEmpty(this._value) ? this._value : func(this._value))
  }

  join () {
    return this._value
  }
}

class Container {
  static of (value) {
    return new Container(value)
  }

  constructor (value) {
    this._value = value
  }

  map (func) {
    return Container.of(func(this._value))
  }
}

module.exports = {
  Maybe,
  Container
}
